home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeScrollPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  6.6 KB  |  295 lines

  1. package com.supercede.forms;
  2.  
  3. import com.supercede.beans.Support;
  4. import java.applet.Applet;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Graphics;
  8. import java.awt.Point;
  9. import java.awt.ScrollPane;
  10. import java.awt.peer.ScrollPanePeer;
  11. import java.io.IOException;
  12. import java.io.InvalidObjectException;
  13. import java.io.ObjectInputStream;
  14. import java.io.Serializable;
  15. import java.util.Vector;
  16.  
  17. public class SuperCedeScrollPane extends ScrollPane implements SuperCedeDesignContainer, SuperCedeContainerListener, Support, Serializable {
  18.    SuperCedeRuntimeInfo runtimeInfo = new SuperCedeRuntimeInfo();
  19.    SuperCedeDesignInfo designInfo = new SuperCedeDesignInfo();
  20.    transient boolean designMode = false;
  21.    transient DesignModeListener formListener = null;
  22.    transient Vector scContainerListeners = null;
  23.    boolean shadowEnabled = super.isEnabled();
  24.    Point shadowLocation = new Point(0, 0);
  25.    int scrollbarDisplayPolicy = 0;
  26.    private static final long serialVersionUID = 1013082004010516614L;
  27.    private static final int _version = 1;
  28.    private int version = 1;
  29.  
  30.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  31.       this.designInfo = null;
  32.       this.runtimeInfo = null;
  33.       SuperCedeHelper.runTimeConstructor(this, var1);
  34.       ((Component)this).setLocation(this.shadowLocation);
  35.       this.validateObject();
  36.    }
  37.  
  38.    public Component[] getContainedComponents() {
  39.       return ((Container)this).getComponents();
  40.    }
  41.  
  42.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  43.       try {
  44.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  45.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  46.          this.runtimeInfo = var1.getRuntimeInfo();
  47.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  48.          SuperCedeHelper.convertContainer((Container)var1, this);
  49.          if (!this.isDesignMode()) {
  50.             this.runtimeInfo = null;
  51.             this.designInfo = null;
  52.          }
  53.       } catch (ClassCastException var3) {
  54.          throw var3;
  55.       }
  56.    }
  57.  
  58.    public SuperCedeDesignInfo getDesignInfo() {
  59.       return this.designInfo;
  60.    }
  61.  
  62.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  63.       return this.runtimeInfo;
  64.    }
  65.  
  66.    public void addComponent(Component var1, Object var2) {
  67.       this.addComponent(var1, var2, -1);
  68.    }
  69.  
  70.    public void addComponent(Component var1, Object var2, int var3) {
  71.       this.add(var1, var2, var3);
  72.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  73.    }
  74.  
  75.    public void add(Component var1, Object var2, int var3) {
  76.       super.add(var1, var2, var3);
  77.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  78.          ((Applet)var1).start();
  79.       }
  80.  
  81.    }
  82.  
  83.    public void removeComponent(int var1) {
  84.       this.removeComponent(((Container)this).getComponent(var1));
  85.    }
  86.  
  87.    public void removeComponent(Component var1) {
  88.       this.runtimeInfo.removeLayoutConstraints(var1);
  89.       this.remove(var1);
  90.    }
  91.  
  92.    public void remove(Component var1) {
  93.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  94.          ((Applet)var1).stop();
  95.       }
  96.  
  97.       super.remove(var1);
  98.    }
  99.  
  100.    public boolean isEnabled() {
  101.       return this.shadowEnabled;
  102.    }
  103.  
  104.    public void setEnabled(boolean var1) {
  105.       this.shadowEnabled = var1;
  106.       if (!this.isDesignMode()) {
  107.          super.setEnabled(var1);
  108.       }
  109.  
  110.    }
  111.  
  112.    public void paint(Graphics var1) {
  113.       if (this.formListener != null) {
  114.          this.formListener.paint(var1);
  115.       }
  116.  
  117.       super.paint(var1);
  118.    }
  119.  
  120.    public void addNotify() {
  121.       if (this.formListener != null) {
  122.          this.formListener.setupParentHWND();
  123.       }
  124.  
  125.       super.addNotify();
  126.       if (this.formListener != null) {
  127.          this.formListener.addedPeer();
  128.       }
  129.  
  130.    }
  131.  
  132.    public void removeNotify() {
  133.       if (this.formListener != null) {
  134.          this.formListener.removingPeer();
  135.       }
  136.  
  137.       super.removeNotify();
  138.    }
  139.  
  140.    public Object getLayoutConstraints(Component var1) {
  141.       return this.runtimeInfo.getLayoutConstraints(var1);
  142.    }
  143.  
  144.    public Object getLayoutConstraints(int var1) {
  145.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  146.    }
  147.  
  148.    public void setDesignMode(boolean var1) {
  149.       this.designMode = var1;
  150.    }
  151.  
  152.    public boolean isDesignMode() {
  153.       return this.designMode;
  154.    }
  155.  
  156.    public void setFormListener(DesignModeListener var1) {
  157.       this.formListener = var1;
  158.    }
  159.  
  160.    public DesignModeListener getFormListener() {
  161.       return this.formListener;
  162.    }
  163.  
  164.    public void doPostSerializeProcessing(boolean var1) {
  165.       Container var2 = ((Component)this).getParent();
  166.       if (var2 instanceof SuperCedeContainer) {
  167.          ((SuperCedeContainer)var2).addSuperCedeContainerListener(this);
  168.       }
  169.  
  170.    }
  171.  
  172.    public void containerShutdown(SuperCedeContainerEvent var1) {
  173.       if (this.scContainerListeners != null) {
  174.          synchronized(this){}
  175.  
  176.          Vector var2;
  177.          try {
  178.             var2 = (Vector)this.scContainerListeners.clone();
  179.          } catch (Throwable var5) {
  180.             throw var5;
  181.          }
  182.  
  183.          for(int var3 = 0; var3 < var2.size(); ++var3) {
  184.             ((SuperCedeContainerListener)var2.elementAt(var3)).containerShutdown(var1);
  185.          }
  186.       }
  187.  
  188.    }
  189.  
  190.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  191.       synchronized(this){}
  192.  
  193.       try {
  194.          if (this.scContainerListeners == null) {
  195.             this.scContainerListeners = new Vector();
  196.          }
  197.  
  198.          this.scContainerListeners.addElement(var1);
  199.       } catch (Throwable var4) {
  200.          throw var4;
  201.       }
  202.  
  203.    }
  204.  
  205.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  206.       synchronized(this){}
  207.  
  208.       try {
  209.          this.scContainerListeners.removeElement(var1);
  210.       } catch (Throwable var4) {
  211.          throw var4;
  212.       }
  213.  
  214.    }
  215.  
  216.    public void setVisible(boolean var1) {
  217.       if (!var1) {
  218.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  219.       }
  220.  
  221.       super.setVisible(var1);
  222.       if (var1) {
  223.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  224.       }
  225.  
  226.    }
  227.  
  228.    public int getScrollbarDisplayPolicy() {
  229.       return this.scrollbarDisplayPolicy;
  230.    }
  231.  
  232.    public void setScrollbarDisplayPolicy(int var1) {
  233.       if (var1 != this.scrollbarDisplayPolicy) {
  234.          switch (var1) {
  235.             case 0:
  236.             case 1:
  237.             case 2:
  238.                this.scrollbarDisplayPolicy = var1;
  239.                Object var2 = ((Component)this).getTreeLock();
  240.                synchronized(var2){}
  241.  
  242.                try {
  243.                   if (((Component)this).getPeer() != null) {
  244.                      this.removeNotify();
  245.                      this.addNotify();
  246.                      ((Container)this).invalidate();
  247.                   }
  248.                } catch (Throwable var4) {
  249.                   throw var4;
  250.                }
  251.  
  252.                return;
  253.             default:
  254.                throw new IllegalArgumentException("illegal scrollbar display policy value");
  255.          }
  256.       }
  257.    }
  258.  
  259.    public int getHScrollbarHeight() {
  260.       int var1 = 0;
  261.       if (this.getScrollbarDisplayPolicy() != 2) {
  262.          ScrollPanePeer var2 = (ScrollPanePeer)((Component)this).getPeer();
  263.          if (var2 != null) {
  264.             var1 = var2.getHScrollbarHeight();
  265.          }
  266.       }
  267.  
  268.       return var1;
  269.    }
  270.  
  271.    public int getVScrollbarWidth() {
  272.       int var1 = 0;
  273.       if (this.getScrollbarDisplayPolicy() != 2) {
  274.          ScrollPanePeer var2 = (ScrollPanePeer)((Component)this).getPeer();
  275.          if (var2 != null) {
  276.             var1 = var2.getVScrollbarWidth();
  277.          }
  278.       }
  279.  
  280.       return var1;
  281.    }
  282.  
  283.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  284.       var1.defaultReadObject();
  285.  
  286.       try {
  287.          SuperCedeHelper.doDeserializationProcessing(this);
  288.       } catch (SuperCedeInvalidStateException var2) {
  289.       }
  290.    }
  291.  
  292.    public void validateObject() throws InvalidObjectException {
  293.    }
  294. }
  295.